class SiteSetting < ActiveRecord::Base
  attr_accessible :description, :key, :value

  def self.create_or_update_from_hash configs = {}
    configs.each do |k, v|
      config = SiteSetting.where(key: k.to_s).first_or_create
      config.update_attribute(:value, v.to_s)
    end
  end

  def self.get_configs *keys
    configs = { }
    keys.each do |k|
      config = SiteSetting.where(key: k.to_s).first
      configs[k] = config ? config.value : nil
    end
    configs
  end
end
